package com.neusoft.liduan.d0922;

public class ThreadHuoChePiao extends Thread{
	private static int i = 100;
	private static Object obj = new Object();
	
	public void run() {
		while(true) {
			synchronized (obj) {
				if(i >= 1) {
					System.out.println(Thread.currentThread() + "卖了第" + i + "张票");
					i--;
					try {
						Thread.sleep(100);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}else {
					break;
				}
			}
		}
	}
}
